package com.vita.core.device.output;

import java.util.List;
import java.util.Queue;

import com.vita.common.FileUtils;
import com.vita.core.function.Func2;

public class TxtOutput implements Func2 {
    private String filename;

    @Override
    public Object apply(Object t) {
        String filename = this.filename;
        if(filename == null){
            filename = "转换后文件-" + (System.currentTimeMillis()% 10000000L) +".txt";
        }
        FileUtils.writeList(filename, (List)t);
        return t;
    }

    @Override
    public void borrow(Queue<Object> bank) {
        this.filename = (String)bank.poll();
    }
}
